package com.galeno.api;

import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;

import java.io.IOException;

/**
 * Author:   galeno
 * Date:     21/08/03
 * Description:
 * 1 删除名称空间
 * 2 删除表
 * 3 修改表
 *   1) 添加列族     admin.addColumnFamily(tb_teacher,cf3);
 *   2) 删除列族     admin.deleteColumnFamily(tb_teacher, "cf3".getBytes());
 *   3) 修改列族属性  admin.modifyColumnFamily(tb_teacher,other);
 */
public class Demo10_CreatePreRegion {

    public static void main(String[] args) throws Exception {
        Admin admin=ConnectionFactory.createConnection(HBaseConfiguration.create()).
                getAdmin();
        TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(TableName.valueOf("tb_c"));
        // cf1
        ColumnFamilyDescriptorBuilder cf1DescriptorBuilder = ColumnFamilyDescriptorBuilder.newBuilder("cf1".getBytes());
        ColumnFamilyDescriptor cf1 = cf1DescriptorBuilder.build();
        tableDescriptorBuilder.setColumnFamily(cf1);
        TableDescriptor tableDescriptor = tableDescriptorBuilder.build();
        byte[][] keys = {"e".getBytes(),"o".getBytes()};
        //参数二  预分region的切割点
        admin.createTable(tableDescriptor ,keys);
        admin.close();


    }
}
